package com.example.joblinker.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.joblinker.dto.ApplicationStatsDTO;
import com.example.joblinker.entity.JobApplication;
import com.example.joblinker.mapper.JobApplicationMapper;
import com.example.joblinker.service.ApplicationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

@Service
public class ApplicationServiceImpl extends ServiceImpl<JobApplicationMapper, JobApplication> implements ApplicationService {
    
    @Override
    public ApplicationStatsDTO getJobApplicationStats(Long jobId) {
        // 创建查询条件
        LambdaQueryWrapper<JobApplication> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(JobApplication::getJobId, jobId);
        
        // 获取总投递数
        long total = count(wrapper);
        
        // 获取待处理数(状态为0的申请)
        wrapper.eq(JobApplication::getStatus, 0);
        long pending = count(wrapper);
        
        // 返回统计数据
        return new ApplicationStatsDTO(jobId, total, pending);
    }
    
    // ... existing code ...
} 